<?php
   $conn= mysql_connect("localhost","root","root") ;
   mysql_select_db("postit");

   $q=mysql_query("INSERT INTO postit.valutators values(".$_REQUEST['postit'].",'".$_REQUEST['valutationAuthor']."');");   
   
   if (!$q || !$conn )
      print(json_encode(null));
   
   else { 
         $q2=mysql_query("UPDATE postit.user SET ranking=".$_REQUEST['ranking'].",valutationsNumber=valutationsNumber+1 WHERE user.username='".$_REQUEST['username']."';"); 
         if ($q2)
            print(json_encode(ok));
         else {
              mysql_query("DELETE FROM postit.valutators WHERE postit=".$_REQUEST['postit']." AND valutationAuthor='".$_REQUEST['valutationAuthor']."';");
              print(json_encode(null));}
   }
   mysql_close();

?>